import {_decorator} from 'cc';
import FSMState from "db://assets/scripts/state/FSMState";

const {ccclass, property} = _decorator;

export default class FSMManager {
    /**
     * 状态列表
     */
    states: FSMState[] = [];
    /**
     * 当前状态ID
     */
    currentStateIndex: number = -1;

    changeState(stateId: number) {
        this.currentStateIndex = stateId;
        this.states[this.currentStateIndex].onEnter();
    }

    onUpdate() {
        if (this.currentStateIndex !== -1) {
            this.states[this.currentStateIndex].onUpdate();
        }
    }
}

